//Page Object
Page({
  data: {
    
  },
  //options(Object)
  onLoad: function(options){
    
  },
  onReady: function(){
    
  },
  onShow: function(){
    
  },
  onHide: function(){

  },
  onUnload: function(){

  },
  onPullDownRefresh: function(){

  },
  onReachBottom: function(){

  },
  onShareAppMessage: function(){

  },
  onPageScroll: function(){

  },
  //item(index,pagePath,text)
  onTabItemTap:function(item){

  },
  loadingToast1(){
    wx.showToast({
      title: '正在加载',
      icon: 'loading',
      image: '',
      duration: 1500,
      mask: true,
      success: (result)=>{
        console.log("加载中....");
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },
  
  modalToast(){
    wx.showModal({
      title: '对话框',
      content: '您的性别',
      showCancel: true,
      cancelText: '男',
      cancelColor: '#000000',
      confirmText: '女',
      confirmColor: '#000000',
      success: (result) => {
        if(result.confirm){
          console.log("选择了女性");
        }else{
          console.log("选择了男性");
        }
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },

  loadingToast2(){
    wx.showToast({
      title: '两秒后JS会关闭弹出框',
      icon: 'none',
      image: '',
      mask: true,
      success: (result)=>{
        setTimeout(() => {
          console.log("手动关闭弹出框");
          wx.hideToast();
        }, 2000);
        
        
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },

  loadingToast3(){
    wx.showLoading({
      title: "loading....",
      mask: true,
      success: (result)=>{
        console.log("该api 必须手动关闭");
        setTimeout(() => {
          wx.hideLoading();
        }, 2000);
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },

  showAction(){
    wx.showActionSheet({
      itemList: ['选项A', '选项B', '选项C'],
      itemColor: '#000000',
      success: (result)=>{
        switch(result.tapIndex){
          case 0: 
            console.log("用户选择了选项A");
            break;
          case 1: 
            console.log("用户选择了选项B");
            break
          case 2: 
            console.log("用户选择了选项C");
              break;
          default:
            console.log("用户选择了其他");
            break;
        }
      },
      fail: ()=>{},
      complete: ()=>{}
    });
  },

  showAlert(){
    wx.enableAlertBeforeUnload({
      message: "这尼玛比什么情况, 为什么没有代码提示呢?",
      success: result=>{
        console.log(result);
      },
      fail: ()=>console.log("complete触发了"),
      complete: ()=>console.log("complete触发了"),
    })
  },

});